package com.sgb.kjwl.view.widget.lease;

import android.content.Context;

import androidx.recyclerview.widget.GridLayoutManager;

import com.sgb.kjwl.R;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.kjwl.view.ui.adapter.pick.PickHallBidingStatusAdapter;
import com.sgb.kjwl.view.widget.MaxHeightRecyclerView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;

import java.util.List;

public class InquiryPopWindow extends BasePopWindow {

    private PickHallBidingStatusAdapter goodsTypeAdapter;
    private PickSelectEntity entity;

    public InquiryPopWindow(Context context) {
        super(context);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_inquiry_type;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        MaxHeightRecyclerView recyclerView = holder.getPop().findViewById(R.id.goods_type_list);

        goodsTypeAdapter = new PickHallBidingStatusAdapter(mContext,null);
        goodsTypeAdapter.setItemSelect(true);
        goodsTypeAdapter.setDefItem(-1);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext,4));
        recyclerView.setAdapter(goodsTypeAdapter);

        goodsTypeAdapter.setOnItemClick(new AdapterOnItemClick<PickSelectEntity>() {
            @Override
            public void onItemClick(PickSelectEntity provinceEntity, int position) {
//                if(null!=entity && entity.getNo().equals(provinceEntity.getNo())){
//                    onResultClick.result(null,null,null);
//                    goodsTypeAdapter.setSelected(false,provinceEntity);
//                }else{
//                    entity = provinceEntity;
                onResultClick.result(provinceEntity,position,null);
//                    goodsTypeAdapter.setSelected(true,provinceEntity);
//                }
                dissMiss();
            }
        });

        holder.getPop().findViewById(R.id.bg_pop_gray_layout).setOnClickListener(view -> dissMiss());
    }

    public void setData(List<PickSelectEntity> list){
        goodsTypeAdapter.setDatas(list);
    }
}
